﻿using System;
using System.Collections.Generic;
using System.Linq;
using System.Reflection;
using System.Text;
using System.Threading.Tasks;
using System.Windows;
using System.Windows.Controls;
using System.Windows.Controls.Primitives;
using System.Windows.Data;
using System.Windows.Documents;
using System.Windows.Input;
using System.Windows.Media;
using System.Windows.Media.Imaging;
using System.Windows.Navigation;
using System.Windows.Shapes;

namespace JustWPFControls.Controls
{
    [TemplatePart(Name ="PART_Track", Type=typeof(Track))]
    [TemplatePart(Name = "PART_SelectionRange", Type=typeof(Border))]
    public class JSlider : Slider
    {
        private Track _track = null!;
        public override void OnApplyTemplate()
        {
            base.OnApplyTemplate();
            _track = (Track)GetTemplateChild("PART_Track");

            _track.Thumb.PreviewMouseLeftButtonDown += (s, e) =>
            {
                var result = _track.Thumb.CaptureMouse();
            };
            _track.Thumb.PreviewMouseLeftButtonUp += (s, e) =>
            {
                _track.Thumb.ReleaseMouseCapture();
            };
        }
        static JSlider()
        {
            DefaultStyleKeyProperty.OverrideMetadata(typeof(JSlider), new FrameworkPropertyMetadata(typeof(JSlider)));
        }
    }
}
